﻿@using QuestionsAnswers.UI.Models
@model IEnumerable<QuestionsAnswers.UI.Models.Question>
@{
    ViewBag.Title = "Questions";
    AjaxOptions opts = new AjaxOptions { OnSuccess = "OnSuccessCreate" };
}
<h2>
    Questions</h2>

<p>
    @Ajax.ActionLink("Create New", "Create", opts)
</p>
<p>
    @{
        using (Html.BeginForm())
        {
        @:Order By:
            @Html.DropDownList("sortType", (List<SelectListItem>)ViewBag.DropDownSortItems, new { onchange = "$(this).parent('form:first').submit();" })
            if (User.Identity.IsAuthenticated)
            {    
        @:Only include course: @Html.DropDownList("courseFilter", (List<SelectListItem>)ViewBag.UsersCourses, new { onchange = "$(this).parent('form:first').submit();" })
            }
        @Html.CheckBox("unansweredFltrChk", (bool)ViewBag.UnsansweredFltr, new { onClick = "$(this).parent('form:first').submit();" })
        @:ViewOnlyUnansweredquestions
            
        }
    }
</p>
@Html.Partial("QuestionsPartial", @Model)
<div>
    @Html.PageLinks((PagingInfo)ViewBag.pagingInfo, x => Url.Action("Index", new { page = x }))
</div>
